﻿using MusicStore.Infrastructure;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MusicStore.Models
{
    // GET: Order
    /// <summary>
    /// 订单
    /// </summary>
    public class Order
    {
        
        public  int OrderId { get; set; }//自动属性
        
        public  DateTime OrderDate { get; set; }
        [DisplayName("账号")]
        public  string Username { get; set; } 
        [Required(ErrorMessage = "姓为非空字段！")]//非空字段
        [DisplayName("姓")]
        //[StringLength(160)]
        [MaxWords(10)]
        public  string FirstName { get; set; } 
        [Required(ErrorMessage = "名为非空字段！")]
        [DisplayName("名")]
        [StringLength(160)]
        //[Compare("FirstName")]//必须和姓匹配
        [DataType(DataType.Password)]//不可视
        public  string LastName { get; set; } 
        [Required(ErrorMessage = "地址为非空字段！")]
        [DisplayName("地址")]
        [StringLength(70)]
        public  string Address { get; set; }  
        [Required(ErrorMessage = "城市为非空字段！")]
        [DisplayName("城市")]
        [StringLength(40)]
        public  string City { get; set; } 
        [Required(ErrorMessage = "区为非空字段！")]
        [DisplayName("区")]
        [StringLength(40)]
        public  string State { get; set; }
        [Required(ErrorMessage = "邮政编码为非空字段！")]
        [DisplayName("邮政编码")]
        [StringLength(6)]
        public  string PostalCode { get; set; } 
        [Required(ErrorMessage = "国籍为非空字段！")]
        [DisplayName("国籍")]
        [StringLength(40)]
        public  string Country { get; set; }
        [Required(ErrorMessage = "电话为非空字段！")]
        [DisplayName("电话")]
        [StringLength(24)]
        public  string Phone { get; set; } 
        [Required(ErrorMessage = "Email为非空字段！")]
        [DisplayName("Email地址")]
        [RegularExpression(@"[A-Za-z0-9 ._％+ - ] + @ [A-Za-z0-9 .-] + \。[A-Za-z] {2,4}")]
        public  string Email { get; set; }
        [Required(ErrorMessage = "总金额为非空字段！")]
        [DisplayName("总金额")]
        [ReadOnly(true)]
        public  decimal Total { get; set; }
        public List<Order> OrderDetails { get; set; }
        public Order()
        {
            this.OrderDate = DateTime.Now;//获取当前时间
        }

    }
    }